package edu.gznu.ics.fast.pulsar.controller.prestoacc.candidateMatchController;

import edu.gznu.ics.fast.common.UIHelper.CandCompareQueryPagiNationHelper;
import edu.gznu.ics.fast.pulsar.model.po.prestoacc.pic.PicInfoPO;
import edu.gznu.ics.fast.pulsar.model.vo.prestoacc.knowPulsar.KnownPulsarCandidateVO;
import edu.gznu.ics.fast.pulsar.model.vo.web.QueryCommandVO;
import edu.gznu.ics.fast.pulsar.service.candMatchService.PulsarMatchCandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * Created by fei-zyx on 2016/11/10.
 */

@Controller
@RequestMapping("/candmatch")

public class CandMatchController {
    @Autowired
    PulsarMatchCandService pulsarMatchCandService;

    @RequestMapping(method = RequestMethod.POST, value = "/requestknowlist", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public List<KnownPulsarCandidateVO> respKnowPulsar(@RequestBody List<QueryCommandVO> queryCommandVO, HttpServletResponse response) throws IOException {
        final int pageSize = 30;
        List<KnownPulsarCandidateVO> knownPulsarCandidatePOList = pulsarMatchCandService.findKonwPulsarList();

        CandCompareQueryPagiNationHelper candCompareQueryPagiNationHelper = new CandCompareQueryPagiNationHelper();
        return candCompareQueryPagiNationHelper.produceMeassage(pageSize, queryCommandVO, knownPulsarCandidatePOList);
        //knownPulsarCandidatePOList;
    }

    @RequestMapping(method = RequestMethod.POST, value = "/pulsarMatchCand", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public List<PicInfoPO> respPicInfo(@RequestBody List<KnownPulsarCandidateVO> knownPulsarCandidateVO,
                                       HttpServletResponse response) throws IOException {
        List<PicInfoPO> picInfoPOs = pulsarMatchCandService.matchPicInfoByPicInfoLists(knownPulsarCandidateVO.get(0));


        return picInfoPOs;
    }

    @RequestMapping(method = RequestMethod.POST, value = "/requestknowlistre", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public List<KnownPulsarCandidateVO> respKnowPulsarre(@RequestBody List<QueryCommandVO> queryCommandVO, HttpServletResponse response) throws IOException {
        final int pageSize = 30;
        List<KnownPulsarCandidateVO> knownPulsarCandidatePOList = pulsarMatchCandService.findKonwPulsarListre();

        CandCompareQueryPagiNationHelper candCompareQueryPagiNationHelper = new CandCompareQueryPagiNationHelper();
        return candCompareQueryPagiNationHelper.produceMeassage(pageSize, queryCommandVO, knownPulsarCandidatePOList);
        //knownPulsarCandidatePOList;
    }

    @RequestMapping(method = RequestMethod.POST, value = "/candMatchPulsar", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public List<KnownPulsarCandidateVO> candMatchPulsar(@RequestBody List<QueryCommandVO> queryCommandVO, HttpServletResponse response) throws IOException {

        List<KnownPulsarCandidateVO> knownPulsarCandidatePOList = pulsarMatchCandService.candMatchPulsar();


        //
//
// final int pageSize=30;
//        List<KnownPulsarCandidateVO> knownPulsarCandidatePOList= pulsarMatchCandService.findKonwPulsarListre();
//
//        CandCompareQueryPagiNationHelper candCompareQueryPagiNationHelper = new  CandCompareQueryPagiNationHelper();
//        return candCompareQueryPagiNationHelper.produceMeassage(pageSize,queryCommandVO,knownPulsarCandidatePOList);
        //knownPulsarCandidatePOList;
        return null;
    }
}
